let mut url = url.clone();
// Strip a trailing slash
- match url.scheme_data {
- url::SchemeData::Relative(ref mut rel) => {
- if rel.path.last().map(|s| s.is_empty()).unwrap_or(false) {
- rel.path.pop();
- }
+ if let url::SchemeData::Relative(ref mut rel) = url.scheme_data {
+ if rel.path.last().map(|s| s.is_empty()).unwrap_or(false) {
+ rel.path.pop();
}
- _ => {}
}
// HACKHACK: For github URL's specifically just lowercase
// same case conversion rules that GitHub does. (#84)
if url.domain() == Some("github.com") {
url.scheme = "https".to_string();
- match url.scheme_data {
- url::SchemeData::Relative(ref mut rel) => {
- rel.port = Some(443);
- rel.default_port = Some(443);
- let path = mem::replace(&mut rel.path, Vec::new());
- rel.path = path.into_iter().map(|s| {
- s.chars().flat_map(|c| c.to_lowercase()).collect()
- }).collect();
- }
- _ => {}
+ if let url::SchemeData::Relative(ref mut rel) = url.scheme_data {
+ rel.port = Some(443);
+ rel.default_port = Some(443);
+ let path = mem::replace(&mut rel.path, Vec::new());
+ rel.path = path.into_iter().map(|s| {
+ s.chars().flat_map(|c| c.to_lowercase()).collect()
+ }).collect();
}
}
// Repos generally can be accessed with or w/o '.git'
- match url.scheme_data {
- url::SchemeData::Relative(ref mut rel) => {
- let needs_chopping = {
- let last = rel.path.last().map(|s| &s[..]).unwrap_or("");
- last.ends_with(".git")
- };
- if needs_chopping {
- let last = rel.path.pop().unwrap();
- rel.path.push(last[..last.len() - 4].to_string())
- }
+ if let url::SchemeData::Relative(ref mut rel) = url.scheme_data {
+ let needs_chopping = {
+ let last = rel.path.last().map(|s| &s[..]).unwrap_or("");
+ last.ends_with(".git")
+ };
+ if needs_chopping {
+ let last = rel.path.pop().unwrap();
+ rel.path.push(last[..last.len() - 4].to_string())
}
- _ => {}
}
url